// @APIVersion 1.0.0
// @Title beego Test API
// @Description beego has a very cool tools to autogenerate documents for your API
// @Contact astaxie@gmail.com
// @TermsOfServiceUrl http://beego.me/
// @License Apache 2.0
// @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
package routers

import (
	"bee-fisco-api/controllers"
	"github.com/astaxie/beego"
	"log"
	"strings"

	"github.com/FISCO-BCOS/go-sdk/client"
	"github.com/FISCO-BCOS/go-sdk/conf"
)

func initClient() (*client.Client, error) {
	return nil, nil
}

func init() {
	configs, err := conf.ParseConfigFile("config.toml")
	if err != nil {
		if strings.Contains(err.Error(), "open file failed") {
			return
		}
		log.Fatal(err)
	}
	config := &configs[0]

	cli, err := client.Dial(config)
	if err != nil {
		log.Fatal(err)
	}

	ns := beego.NewNamespace("/v1",
		beego.NSNamespace("/object",
			beego.NSInclude(
				&controllers.ObjectController{},
			),
		),
		beego.NSNamespace("/user",
			beego.NSInclude(
				&controllers.UserController{},
			),
		),
	)

	beego.AddNamespace(ns)
	beego.Router("/hello", &controllers.HelloController{Cli: cli})
	//beego.Router("/register", &controllers.RegisterController{})
	beego.Router("/zhuce", &controllers.ZhuceController{})
}
